#include "../logs/log.h"



void test_log(const std::string &name)
{
    DEBUG("%s","开始测试...");
    Hxy_Log::Logger::ptr logger = Hxy_Log::LoggerManager::GetInstance().getLogger(name);
    logger->debug("%s","日志测试");
    logger->info("%s","日志测试");
    logger->warn("%s","日志测试");
    logger->error("%s","日志测试");
    logger->fatal("%s","日志测试");
    DEBUG("%s","结束测试...");
}

int main()
{
    std::unique_ptr<Hxy_Log::LoggerBuilder> ptr(new Hxy_Log::GlobalLoggerBuilder());//创建全局日志器建造
    ptr->BuildLoggerName("sync-logger");   //建造日志器名字
    ptr->BuildLoggerType(Hxy_Log::LoggerType::SYNCTYPE);   //建造日志器类型 -- 同步和异步
    ptr->BuildLoggerValue(Hxy_Log::LogLevel::value::DEBUG);  //建造日志限制输出等级
    ptr->BuildFormatter();  //建造日志输出格式
    ptr->BuildSink<Hxy_Log::StdOutSink>();  //建造日志落地方式 -- 标准输出|输入文件|滚动输入文件
    ptr->BuildSink<Hxy_Log::FileSink>("./logfile/syc.log");
    ptr->BuildSink<Hxy_Log::RollFillSizeSink>("./logfile/roll-", 1024 * 1024);
    ptr->build();   //组装

    test_log("sync-logger");

    return 0;
}
